import { createRouter, createWebHistory } from 'vue-router'
import homepage  from '../views/home/HomePage.vue'
import Layout from '@/layout/Layout.vue';
import AdminLayout from '@/views/backend/AdminLayout.vue';
import ArticleManagement from '@/views/backend/Article/ArticleManagement.vue';
import Settings from '@/views/backend/Settings.vue';
import ArticleAdd from '@/views/backend/Article/ArticleAdd.vue';
import ArticleListView from '@/views/home/Article/ArticleListView.vue';
import ArticleDetail from '@/views/home/Article/ArticleDetail.vue'; // 文章详情页面
import AboutView from '@/views/AboutView.vue';
import messages from '@/views/leave_message.vue';
import  tag  from '@/views/backend/tag/TagManagement.vue';
import resume from '@/views/home/resume.vue';


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        { path: '', component: homepage },
        { path: '/home', component: homepage },
        { path: '/articles', component: ArticleListView },
        {
          path: '/blog/:id', // 动态路由，docId 是语雀文档的唯一标识
          component: ArticleDetail,
          props: true, // 将路由参数作为 props 传递给组件
        },
        {
          path: '/about',
          name: 'about',
          component: AboutView,
        },
        {
          path: '/messages',
          name: 'messages',
          component: messages,
        },
        {
          path: '/resume',
          name: 'resume',
          component: resume,
        },
      ]
    },
    
    {
      path: '/admin',
      component: AdminLayout,
      children: [
        { path: '', component: ArticleManagement },
        { path: 'articles', component: ArticleManagement },
        { path: 'articles/add', component: ArticleAdd }, // 添加文章
        { path: 'settings', component: Settings },
        { path: 'tags', component: tag },
      ],
    },
   
  ],
})

export default router
